package cn.edu.sgu.www.mhxysy.controller.system;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.easyui.component.impl.Tree;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.system.MenuService;
import cn.edu.sgu.www.mhxysy.vo.system.MenuVO;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "菜单管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@RestController
@RequestMapping(path = "/menu", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class MenuController {

	private final MenuService menuService;

	@Autowired
	public MenuController(MenuService menuService) {
		this.menuService = menuService;
	}

	@SuppressWarnings("all")
	@ApiOperation("查询角色的菜单树")
	@RequestMapping(value = "/getMenuTree", method = RequestMethod.GET)
	public JsonResult<List<Tree>> getMenuTree() {
		List<Tree> list = menuService.getMenuTree();

		return JsonResult.success(null, list);
	}

	@ApiOperation("查询角色的侧栏菜单")
	@RequestMapping(value = "/getLeftMenu", method = RequestMethod.GET)
	public JsonResult<List<MenuVO>> getLeftMenu() {
		List<MenuVO> list = menuService.getLeftMenu();

		return JsonResult.success(null, list);
	}

}